package com.nineclock.approve.utils;

import java.util.Arrays;

public class ActivitiUtils {

    //key相关
    public static final String PROCESS_PREFIX = "process_";
    public static final String GATEWAY_PREFIX = "gateway_";
    public static final String USERTASK_PREFIX = "usertask_";
    public static final String USERS_PREFIX = "users_";
    public static final String SEQUENCEFLOW_PREFIX = "seq_";
    public static final String START_PREFIX = "start_";
    public static final String END_PREFIX = "end_";

    //流程定义中匹配相关
    public static final String COND_EXPRESS_USER_SYMBOL_DEPARTMENT = "inDepatment";
    public static final String COND_EXPRESS_USER_SYMBOL_USER = "inUser";
    public static final String PATTERN_START_USER_SYMBOL_EXPRESS = "\\$\\{startUserId\\}\\s*(inDepartment|inUser)\\s*\\[([^\\&\\&|\\|\\||\\(|\\)]*)\\]";
    public static final String PATTERN_CURR_USER_SYMBOL_EXPRESS = "\\$\\{currUserId\\}\\s*(inDepartment|inUser)\\s*\\[([^\\&\\&|\\|\\||\\(|\\)]*)\\]";
    public static final String PATTERN_GET_PRIORITY = "\\$\\{priority\\}='(\\d+)'";


    public static String getKey(String type, String sufix) {
        if ("process".equals(type)) {
            return PROCESS_PREFIX + sufix;
        } else if ("condition".equals(type)) {
            return GATEWAY_PREFIX + sufix;
        } else if (Arrays.asList("CCList", "approval").contains(type)) {
            return USERTASK_PREFIX + sufix;
        } else if ("start".equals(type)) {
            return START_PREFIX + sufix;
        } else if ("end".equals(type)) {
            return END_PREFIX + sufix;
        } else if ("seq".equals(type)) {
            return SEQUENCEFLOW_PREFIX + sufix;
        }
        return null;
    }
}